#!/bin/bash

# nvcc -o bin/reduce_base reduce_add_base.cu -lineinfo && sudo /usr/local/cuda/bin/ncu --set full ./bin/reduce_base | grep "Memory Throughput"


FnCompileAndExe() {
    file=$1
    bin_name=${file%.*}
    echo "file: "${file}, "bin_name: "${bin_name}
    output=$(nvcc -o bin/${bin_name} ${file} -lineinfo && sudo /usr/local/cuda/bin/ncu --set full ./bin/${bin_name})
    echo "${output}" | grep "Memory Throughput"
    echo "${output}" | grep "Time"
}

FnCompileAndExe $*